﻿'use strict';
app.controller('NewsDailyController', function ($scope, $rootScope, $localStorage, NewsFactory) {


    $scope.NewsList = [],
    getListNews($localStorage.user.UserId);

    function getListNews() {
        NewsFactory.getListNews().then(function (response) {
            $scope.NewsList = response.data.Result;
        }, function (error) {
            $scope.status = 'Unable to load News List data: ' + error.message;
        });
    }

});

app.controller('NewsDetailController', function ($scope, $rootScope, $localStorage, $stateParams, NewsFactory) {

    $scope.NewsDetail = {},
    getNewsDetail($stateParams.id);
    function getNewsDetail(id) {
        NewsFactory.getNewsDetail(id).then(function (response) {
            $scope.NewsDetail = response.data.Result;
        }, function (error) {
            $scope.status = 'Unable to load News List data: ' + error.message;
        });
    }

});

